const app = getApp();
import { list } from '../../../../api/mine/rule';

Page({
  data: {
    back: true,
    title: '协议规则',
    loading: true,
    list: null,
    form: {
      page: 1,
      limit: 10
    },
    abnor: {
      title: '未搜索到相关数据~',
      button: ''
    }
  },
  onLoad(options) {
    this.setData({
      loading: true,
      list: []
    });
    list(this.data.form).then(res => {
      this.setData({ list: res.data });
    })
      .finally(() => {
        this.setData({ loading: false });
      });
  },

  //===================methon================

  getList(res) {
    let list = this.data.list.concat(res.data.data);
    let form = this.data.form;
    form.last_page = res.data.last_page;
    this.setData({
      list: list,
      form: form,
      loadmore: res.data.last_page <= 1
    });
  },

  redirect(event) {
    app.redirect(event.currentTarget.dataset.url)
  }
})